Skip to content

fix(axios-sdk): 路径参数兜底提取 (issue #27)#195

Open
yourtion wants to merge 1 commit into
mainfrom
fix/path-params-sdk-gen
Open

fix(axios-sdk): 路径参数兜底提取 (issue #27)#195
yourtion wants to merge 1 commit into
mainfrom
fix/path-params-sdk-gen

Conversation

@yourtion

@yourtion yourtion commented Jul 1, 2026

Copy link
Copy Markdown
Owner

关联 issue

Closes #27

问题

generate_axiosgetPathParams 只读 paramsSchema,而 getReqSendPath 只看路径串,两者脱节。当路由为 /:id 但用户未声明 params schema 时,生成的请求路径引用了变量 id,函数签名却没有 id 参数 → 生成引用未定义变量的坏 SDK

修复

getPathParamsparamsSchema 为空时,从 realPath:xxx 兜底提取参数名,保证签名与路径一致。已声明 paramsSchema 的场景行为不变。

测试

  • 新增 3 个回归测试(声明 params / 未声明 fallback / 无路径参数)
  • 全量 npm run test:lib:317 → 320 全绿
  • tsc --noEmit 通过

版本

bump 3.2.1 → 3.2.3,已登记 MIGRATION

合并顺序提示

本系列共 4 个 PR,请按版本号顺序合并(3.2.2 → 3.2.3 → 3.2.4 → 3.2.5)。
⚠️ 合并时 MIGRATION.mdpackage.json 可能与已合并的 PR 冲突,需在合并时 rebase 解冲突(保留双方版本号递增)。

@codecov

codecov Bot commented Jul 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.55%. Comparing base (ffe0ffa) to head (341cffd).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #195   +/-   ##
=======================================
  Coverage   92.54%   92.55%           
=======================================
  Files          28       28           
  Lines        2939     2942    +3     
  Branches      770      772    +2     
=======================================
+ Hits         2720     2723    +3     
  Misses        217      217           
  Partials        2        2           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

getPathParams 此前只读 paramsSchema,与 getReqSendPath(看路径串)脱节。
当路由为 /:id 但未声明 params schema 时,生成路径引用了 id 变量,
函数签名却没有 id 参数 → 坏 SDK。

现在 getPathParams 在 paramsSchema 为空时从 realPath 的 :xxx 兜底提取,
保证签名与路径一致。已声明 paramsSchema 的场景行为不变。

- 新增 3 个回归测试(声明 params / 未声明 fallback / 无路径参数)
- bump 版本 3.2.1 → 3.2.3,登记 MIGRATION
@yourtion yourtion force-pushed the fix/path-params-sdk-gen branch from 0612939 to 341cffd Compare July 9, 2026 05:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

参数为/:xxxxx格式的路由生成的param.gen.ts缺少相对应的参数导致api.gen.ts出错

1 participant